<template>
	<view class="container">
		<view class="prompt">
			<image :src="data.image" mode="scaleToFill" class="img"></image>
			<view class="title">
				{{ statusCode[data.status].title }}
			</view>
		</view>
		<view class="text" v-if="data.status !== 'Rejected'">
			{{ statusCode[data.status].text }}
		</view>
		<view class="text" v-else>
			{{ data.applicationNotes || '' }}
		</view>
		<view class="footer">
			<button class="btn" v-if="data.status !== 'Rejected'" open-type="contact">联系客服</button>
			<button class="btn" v-else @click="backTo">返回修改</button>
			<button class="btn2"  v-if="data.status === 'Approved'" @click="onPay">付款</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			data: {},
			type: null,
			statusCode: {
				Pending: { title: '提交成功', text: '平台预计在2个工作日内审核，请耐心等候您也可以主动联系牙荷客服' },
				Approved: { title: '审核通过', text: '您的资料已审核通过，牙荷客服将会与您取得联系 您也可以主动联系牙荷客服' },
				Rejected: { title: '审核不通过', text: '平台预计在2个工作日内审核，请耐心等候您也可以主动联系牙荷客服' }
			}
		};
	},
	onLoad(option) {
		this.type = Number(option.type);
		this.$post('/yahe/store/detail', { type: this.type }).then((res) => {
			if (res.success) {
				this.data = res.content;
				if (this.data.status === 'Rejected') {
					this.data.image = '/static/mine/wran.png';
				} else {
					this.data.image = 'https://fine-yahe.oss-cn-shanghai.aliyuncs.com/app/empty/success.png';
				}
			} else {
				this.$toast(res.message, 'none');
			}
		});
	},
	methods: {
		onPay() {
			this.$post('/yahe/order/create/level', { type: this.type })
				.then((res) => {
					if (res.success) {
						uni.navigateTo({
							url: `/mineComponentPackage/component/payment?orderId=${res?.content?.orderId}`
						});
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					}
				})
				.catch((res) => {
					// uni.hideLoading();
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				});
		},
		backTo() {
			uni.navigateTo({
				url: `/mineComponentPackage/serviceCentre/institution?type=${this.type}
				&isEdit=true`
			});
		}
	}
};
</script>

<style scoped lang="less">
.container {
	display: flex;
	justify-content: center;
	flex-direction: column;
	align-items: center;
	font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
	height: 800rpx;
	gap: 20rpx;
	padding: 40rpx;
	.prompt {
		display: flex;
		flex-direction: column;
		gap: 40rpx;
		align-items: center;
		margin-bottom: 40rpx;;
		.img {
			width: 148rpx;
			height: 148rpx;
		}
		.title {
			font-weight: 500;
			font-size: 40rpx;
			color: #3a3a3a;
		}
	}
	.text {
		font-weight: 400;
		font-size: 26rpx;
		color: #3a3a3a;
		margin-bottom: 40rpx;
	}
	.footer {
		.btn {
			width: 236rpx;
			height: 74rpx;
			background: linear-gradient(90deg, #29d8c6 0%, #10beaf 100%);
			border-radius: 76rpx 76rpx 76rpx 76rpx;
			color: white;
			line-height: 74rpx;
			font-weight: 500;
			font-size: 28rpx;
			color: #ffffff;
		}
		.btn2 {
			width: 236rpx;
			height: 74rpx;
			border-radius: 76rpx 76rpx 76rpx 76rpx;
			border: 2rpx solid #10beaf;
			line-height: 74rpx;
			font-size: 28rpx;
			color: #10beaf;
			font-weight: 500;
			margin-top: 20rpx;
		}
	}
}
</style>
